class Solution {
public:
    vector<int> countBits(int n) {
        vector<int> ans(n+1);
        for(int i=0;i<=n;i++)
        {
            unsigned int ret=0;
            int n=i;
            while(n)
            {
                ret+=(n&1);
                n>>=1;
            }
            ans[i]=ret;
        }
        return ans;
    }
};
